#!/usr/bin/env python
# coding: utf-8

# In[2]:


import pandas as pd
pd.plotting.register_matplotlib_converters()
import matplotlib.pyplot as plt
get_ipython().run_line_magic('matplotlib', 'inline')
import seaborn as sns
import matplotlib.dates as mdates
import numpy as np # linear algebra
from sklearn.metrics import mean_absolute_error, mean_squared_error
from sklearn.model_selection import train_test_split
import math   
from datetime import datetime, date 
import warnings
warnings.filterwarnings('ignore')
from tensorflow import keras
from tensorflow.keras import layers
from keras.models import Sequential
from keras.layers import Dense

print("Setup Complete")


# # Fig7

# In[75]:


dam = pd.read_csv("s1_ds_sce_inflow.csv", encoding= 'cp949')
dam.head()


# In[76]:


dam.columns = ['date','obs', '1', '0.6', '0.8', '1.2', '1.4']
dam.head()


# In[77]:


dam["date"] = pd.to_datetime(dam["date"])
dam.index = dam["date"]


# In[78]:


A=pd.DataFrame(dam['0.6'])
B=pd.DataFrame(dam['0.8'])
C=pd.DataFrame(dam['1'])
D=pd.DataFrame(dam['1.2'])
E=pd.DataFrame(dam['1.4'])


# In[82]:


fig = plt.figure(figsize=(20, 7))
ax = fig.add_subplot(1, 1, 1)

ax.plot(A, label='-40%', color='r', linestyle='--', linewidth=3)
ax.plot(B, label='-20%', color='gold', linestyle='--', linewidth=3)
ax.plot(C, label='Control', color='darkgreen', linewidth=3)
ax.plot(D, label='+20%', color='dodgerblue', linestyle='--', linewidth=3)
ax.plot(E, label='+40%', color='mediumorchid', linestyle='--', linewidth=3)
ax.set_ylabel('Water Level (EL.m)', fontsize=35)
plt.xticks(fontsize=25)
plt.yticks(fontsize=27)
plt.ylim(168,204)
plt.grid(True)

ax.spines['bottom'].set_linewidth(2)
ax.spines['top'].set_linewidth(2)
ax.spines['left'].set_linewidth(2)
ax.spines['right'].set_linewidth(2)

ax.legend(fontsize=25,loc='upper left', ncol=5, edgecolor='black') 
plt.savefig('scenario_seomjin_i.png', dpi=300) 
plt.show()


# In[68]:


dam = pd.read_csv("s1_ds_sce_rainfall.csv", encoding= 'cp949')
dam.head()


# In[69]:


dam.columns = ['date','obs', '1', '0.6', '0.8', '1.2', '1.4']
dam.head()


# In[70]:


dam["date"] = pd.to_datetime(dam["date"])
dam.index = dam["date"]


# In[71]:


A=pd.DataFrame(dam['0.6'])
B=pd.DataFrame(dam['0.8'])
C=pd.DataFrame(dam['1'])
D=pd.DataFrame(dam['1.2'])
E=pd.DataFrame(dam['1.4'])


# In[74]:


fig = plt.figure(figsize=(20, 7))
ax = fig.add_subplot(1, 1, 1)

ax.plot(A, label='-40%', color='r', linestyle='--', linewidth=3)
ax.plot(B, label='-20%', color='gold', linestyle='--', linewidth=3)
ax.plot(C, label='Control', color='darkgreen', linewidth=3)
ax.plot(D, label='+20%', color='dodgerblue', linestyle='--', linewidth=3)
ax.plot(E, label='+40%', color='mediumorchid', linestyle='--', linewidth=3)
ax.set_ylabel('Water Level (EL.m)', fontsize=35)
plt.xticks(fontsize=25)
plt.yticks(fontsize=27)
plt.ylim(176,203)
plt.grid(True)

ax.spines['bottom'].set_linewidth(2)
ax.spines['top'].set_linewidth(2)
ax.spines['left'].set_linewidth(2)
ax.spines['right'].set_linewidth(2)

# 가로로 길게 나타내는 레전드 설정
ax.legend(fontsize=25,loc='upper left', ncol=5, edgecolor='black') 
plt.savefig('scenario_seomjin_r.png', dpi=300) 
plt.show()


# In[56]:


dam = pd.read_csv("s1_ds_sce_outflow.csv", encoding= 'cp949')
dam.head()


# In[57]:


dam.columns = ['date','obs', '1', '0.6', '0.8', '1.2', '1.4']
dam.head()


# In[59]:


dam = dam.reset_index(drop=True)


# In[61]:


dam["date"] = pd.to_datetime(dam["date"])
dam.index = dam["date"]


# In[62]:


A=pd.DataFrame(dam['0.6'])
B=pd.DataFrame(dam['0.8'])
C=pd.DataFrame(dam['1'])
D=pd.DataFrame(dam['1.2'])
E=pd.DataFrame(dam['1.4'])


# In[67]:


fig = plt.figure(figsize=(20, 7))
ax = fig.add_subplot(1, 1, 1)

ax.plot(A, label='-40%', color='r', linestyle='--', linewidth=3)
ax.plot(B, label='-20%', color='gold', linestyle='--', linewidth=3)
ax.plot(C, label='Control', color='darkgreen', linewidth=3)
ax.plot(D, label='+20%', color='dodgerblue', linestyle='--', linewidth=3)
ax.plot(E, label='+40%', color='mediumorchid', linestyle='--', linewidth=3)
ax.set_ylabel('Water Level (EL.m)', fontsize=35)
plt.xticks(fontsize=25)
plt.yticks(fontsize=27)
plt.ylim(167,207)
plt.grid(True)

ax.spines['bottom'].set_linewidth(2)
ax.spines['top'].set_linewidth(2)
ax.spines['left'].set_linewidth(2)
ax.spines['right'].set_linewidth(2)

ax.legend(fontsize=25,loc='upper left', ncol=5, edgecolor='black')
plt.savefig('scenario_seomjin_o.png', dpi=300) 
plt.show()


# # Fig8

# In[51]:


dam = pd.read_csv("s2_ds_sce_inflow.csv", encoding= 'cp949')
dam.head()


# In[52]:


dam.columns = ['date','obs', '1', '0.6', '0.8', '1.2', '1.4']
dam.head()


# In[53]:


dam["date"] = pd.to_datetime(dam["date"])
dam.index = dam["date"]


# In[54]:


A=pd.DataFrame(dam['0.6'])
B=pd.DataFrame(dam['0.8'])
C=pd.DataFrame(dam['1'])
D=pd.DataFrame(dam['1.2'])
E=pd.DataFrame(dam['1.4'])


# In[55]:


fig = plt.figure(figsize=(20, 7))
ax = fig.add_subplot(1, 1, 1)

ax.plot(A, label='-40%', color='r', linestyle='--', linewidth=3)
ax.plot(B, label='-20%', color='gold', linestyle='--', linewidth=3)
ax.plot(C, label='Control', color='darkgreen', linewidth=3)
ax.plot(D, label='+20%', color='dodgerblue', linestyle='--', linewidth=3)
ax.plot(E, label='+40%', color='mediumorchid', linestyle='--', linewidth=3)
ax.set_ylabel('Water Level (EL.m)', fontsize=35)
plt.xticks(fontsize=25)
plt.yticks(fontsize=27)
plt.grid(True)
plt.ylim(84,118)

ax.spines['bottom'].set_linewidth(2)
ax.spines['top'].set_linewidth(2)
ax.spines['left'].set_linewidth(2)
ax.spines['right'].set_linewidth(2)

ax.legend(fontsize=25, loc='upper left', ncol=5, edgecolor='black')
plt.savefig('scenario_juam_i.png', dpi=300) 

plt.show()


# In[39]:


dam = pd.read_csv("s2_ds_sce_rainfall.csv", encoding= 'cp949')
dam.head()


# In[40]:


dam.columns = ['date','obs', '1', '0.6', '0.8', '1.2', '1.4']
dam.head()


# In[41]:


dam["date"] = pd.to_datetime(dam["date"])
dam.index = dam["date"]


# In[42]:


A=pd.DataFrame(dam['0.6'])
B=pd.DataFrame(dam['0.8'])
C=pd.DataFrame(dam['1'])
D=pd.DataFrame(dam['1.2'])
E=pd.DataFrame(dam['1.4'])


# In[50]:


fig = plt.figure(figsize=(20, 7))
ax = fig.add_subplot(1, 1, 1)

ax.plot(A, label='-40%', color='r', linestyle='--', linewidth=3)
ax.plot(B, label='-20%', color='gold', linestyle='--', linewidth=3)
ax.plot(C, label='Control', color='darkgreen', linewidth=3)
ax.plot(D, label='+20%', color='dodgerblue', linestyle='--', linewidth=3)
ax.plot(E, label='+40%', color='mediumorchid', linestyle='--', linewidth=3)
ax.set_ylabel('Water Level (EL.m)', fontsize=35)
plt.xticks(fontsize=25)
plt.yticks(fontsize=27)
plt.grid(True)
plt.ylim(88,113)

ax.spines['bottom'].set_linewidth(2)
ax.spines['top'].set_linewidth(2)
ax.spines['left'].set_linewidth(2)
ax.spines['right'].set_linewidth(2)

ax.legend(fontsize=25, loc='upper left', ncol=5, edgecolor='black') 
plt.savefig('scenario_juam_r.png', dpi=300) 
plt.show()


# In[97]:


dam = pd.read_csv("s2_ds_sce_outflow.csv", encoding= 'cp949')
dam.head()


# In[98]:


dam.columns = ['date','obs', '1', '0.6', '0.8', '1.2', '1.4']
dam.head()


# In[99]:


dam = dam.reset_index(drop=True)


# In[101]:


dam["date"] = pd.to_datetime(dam["date"])


# In[102]:


dam.index = dam["date"]


# In[103]:


A=pd.DataFrame(dam['0.6'])
B=pd.DataFrame(dam['0.8'])
C=pd.DataFrame(dam['1'])
D=pd.DataFrame(dam['1.2'])
E=pd.DataFrame(dam['1.4'])


# In[104]:


fig = plt.figure(figsize=(20, 7))
ax = fig.add_subplot(1, 1, 1)

ax.plot(A, label='-40%', color='r', linestyle='--', linewidth=3)
ax.plot(B, label='-20%', color='gold', linestyle='--', linewidth=3)
ax.plot(C, label='Control', color='darkgreen', linewidth=3)
ax.plot(D, label='+20%', color='dodgerblue', linestyle='--', linewidth=3)
ax.plot(E, label='+40%', color='mediumorchid', linestyle='--', linewidth=3)
#ax.set_title('Inflow', fontsize=33)
ax.set_ylabel('Water Level (EL.m)', fontsize=35)
plt.xticks(fontsize=25)
plt.yticks(fontsize=27)
plt.ylim(87,115.5)
plt.grid(True)

# 그래프 가장자리 굵게 설정
ax.spines['bottom'].set_linewidth(2)
ax.spines['top'].set_linewidth(2)
ax.spines['left'].set_linewidth(2)
ax.spines['right'].set_linewidth(2)

# 가로로 길게 나타내는 레전드 설정
ax.legend(fontsize=25,loc='upper left', ncol=5, edgecolor='black') #title="Inflow", title_fontsize=20,  loc=(0.01,0.8),
plt.savefig('scenario_juam_o.png', dpi=300) # PNG로 저장
#ax.tick_params(axis='x',  labelsize=25) #rotation=10,
plt.show()


# # Fig9

# In[105]:


dam = pd.read_csv("s3_ds_sce_inflow.csv", encoding= 'cp949')
dam.head()


# In[106]:


dam.columns = ['date','obs', '1', '0.6', '0.8', '1.2', '1.4']
dam.head()


# In[107]:


dam["date"] = pd.to_datetime(dam["date"])
dam.index = dam["date"]


# In[108]:


A=pd.DataFrame(dam['0.6'])
B=pd.DataFrame(dam['0.8'])
C=pd.DataFrame(dam['1'])
D=pd.DataFrame(dam['1.2'])
E=pd.DataFrame(dam['1.4'])


# In[116]:


fig = plt.figure(figsize=(20, 7))
ax = fig.add_subplot(1, 1, 1)

ax.plot(A, label='-40%', color='r', linestyle='--', linewidth=3)
ax.plot(B, label='-20%', color='gold', linestyle='--', linewidth=3)
ax.plot(C, label='Control', color='darkgreen', linewidth=3)
ax.plot(D, label='+20%', color='dodgerblue', linestyle='--', linewidth=3)
ax.plot(E, label='+40%', color='mediumorchid', linestyle='--', linewidth=3)

ax.set_ylabel('Water Level (EL.m)', fontsize=35)
plt.xticks(fontsize=25)
plt.yticks(fontsize=27)
plt.grid(True)
plt.ylim(84,123)

ax.spines['bottom'].set_linewidth(2)
ax.spines['top'].set_linewidth(2)
ax.spines['left'].set_linewidth(2)
ax.spines['right'].set_linewidth(2)

ax.legend(fontsize=25, loc='upper left', ncol=5, edgecolor='black') #title="Inflow", title_fontsize=20,  
plt.savefig('scenario_juam_control_i.png', dpi=300) 
plt.show()


# In[135]:


dam = pd.read_csv("s3_ds_sce_rainfall.csv", encoding= 'cp949')
dam.head()


# In[136]:


dam.columns = ['date','obs', '1', '0.6', '0.8', '1.2', '1.4']
dam.head()


# In[137]:


dam["date"] = pd.to_datetime(dam["date"])
dam.index = dam["date"]


# In[138]:


A=pd.DataFrame(dam['0.6'])
B=pd.DataFrame(dam['0.8'])
C=pd.DataFrame(dam['1'])
D=pd.DataFrame(dam['1.2'])
E=pd.DataFrame(dam['1.4'])


# In[139]:


fig = plt.figure(figsize=(20, 7))
ax = fig.add_subplot(1, 1, 1)

ax.plot(A, label='-40%', color='r', linestyle='--', linewidth=3)
ax.plot(B, label='-20%', color='gold', linestyle='--', linewidth=3)
ax.plot(C, label='Control', color='darkgreen', linewidth=3)
ax.plot(D, label='+20%', color='dodgerblue', linestyle='--', linewidth=3)
ax.plot(E, label='+40%', color='mediumorchid', linestyle='--', linewidth=3)
ax.set_ylabel('Water Level (EL.m)', fontsize=35)
plt.xticks(fontsize=25)
plt.yticks(fontsize=27)
plt.grid(True)
plt.ylim(89,110)

ax.spines['bottom'].set_linewidth(2)
ax.spines['top'].set_linewidth(2)
ax.spines['left'].set_linewidth(2)
ax.spines['right'].set_linewidth(2)

ax.legend(fontsize=25, loc='upper left', ncol=5, edgecolor='black') 
plt.savefig('scenario_juam_control_r.png', dpi=300) 
plt.show()


# In[127]:


dam = pd.read_csv("s3_ds_sce_outflow.csv", encoding= 'cp949')
dam.head()


# In[128]:


dam.columns = ['date','obs', '1', '0.6', '0.8', '1.2', '1.4']
dam.head()


# In[129]:


dam = dam.reset_index(drop=True)


# In[130]:


dam[25150:25155]


# In[131]:


dam["date"] = pd.to_datetime(dam["date"])
dam.index = dam["date"]


# In[132]:


A=pd.DataFrame(dam['0.6'])
B=pd.DataFrame(dam['0.8'])
C=pd.DataFrame(dam['1'])
D=pd.DataFrame(dam['1.2'])
E=pd.DataFrame(dam['1.4'])


# In[134]:


fig = plt.figure(figsize=(20, 7))
ax = fig.add_subplot(1, 1, 1)

ax.plot(A, label='-40%', color='r', linestyle='--', linewidth=3)
ax.plot(B, label='-20%', color='gold', linestyle='--', linewidth=3)
ax.plot(C, label='Control', color='darkgreen', linewidth=3)
ax.plot(D, label='+20%', color='dodgerblue', linestyle='--', linewidth=3)
ax.plot(E, label='+40%', color='mediumorchid', linestyle='--', linewidth=3)
ax.set_ylabel('Water Level (EL.m)', fontsize=35)
plt.xticks(fontsize=25)
plt.yticks(fontsize=27)
plt.grid(True)
plt.ylim(89,111)

ax.spines['bottom'].set_linewidth(2)
ax.spines['top'].set_linewidth(2)
ax.spines['left'].set_linewidth(2)
ax.spines['right'].set_linewidth(2)

ax.legend(fontsize=25, loc='upper left', ncol=5, edgecolor='black') 
plt.savefig('scenario_juam_control_o.png', dpi=300) 
plt.show()


# In[ ]:




